package com.example.maybeaccount;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.example.maybeaccount.R;

public class InputDialog extends Dialog {

    private Context  context;
    private Button   button_sure;
    private TextView tv_value;
    private EditText text_amount ;

    /**
     * 自定义Dialog监听器
     */

    public interface PriorityListener {

        /**
         * 回调函数，用于在Dialog的监听事件触发后刷新Activity的UI显示
         */

        void setActivityText(String string);

        void setAccountData(String name,String category,String amount,String remark);

    }



    private PriorityListener listener;

    public InputDialog (Context context,int theme,PriorityListener listener){
        super(context, theme);

        this.context = context;

        this.listener = listener;
    }

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        LayoutInflater inflate = LayoutInflater.from(context);

        View view = inflate.inflate(R.layout.activity_input_amout, null);

        setContentView(view);

        button_sure = (Button) view.findViewById(R.id.button_sure);

        final EditText editText = (EditText) view.findViewById(R.id.edit_inputamount);


        button_sure.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {
                String input = editText.getText().toString();
                if(!input.equals("")){
                    listener.setActivityText(input);
                    listener.setAccountData("nul","nul",input,"nul");
                }
                dismiss();
            }
        });

    }

}